<?php
// 管理员登录
header("content-type:text/html;charset=utf-8");
include_once("conn.php");

$a_id = $_POST['a_id'];
$a_pwd = $_POST['a_password'];

$sql = "SELECT * FROM tb_admin_info WHERE aid = '" . $a_id . "'";
$result = mysqli_query($conn, $sql);
if (!$result) {
    echo "<script>alert('数据获取失败！');history.go(-1);</script>";
} else {
    if (mysqli_num_rows($result) > 0) {
        $info = mysqli_fetch_assoc($result);
        if ($info['apassword'] == $a_pwd) {
            session_start();
            $_SESSION['ADMININFOS'] = $info;
            echo "<script>window.location.href='../a-main.php';</script>";
        } else {
            echo "<script>alert('密码错误！');history.go(-1);</script>";
        }
    } else {
        echo "<script>alert('不存在该管理员！');history.go(-1);</script>";
    }
}
